Imports System.Windows.Forms
Imports KanBan.Pgd.Infrastructure.Exceptions

Public Class MessageDialog

    Public Sub New(ByVal dialogType As MessageDialogType, ByVal errorList As IList(Of ApplicationError))

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        InitializeView(dialogType, errorList)

    End Sub

    Private Sub InitializeView(ByVal dialogType As MessageDialogType, ByVal errorList As IList(Of ApplicationError))

        SetDialogImage(dialogType)

        For Each ae As ApplicationError In errorList
            txtMessage.Text += ae.Message + Environment.NewLine
        Next

    End Sub

    Public Sub New(ByVal dialogType As MessageDialogType, ByVal message As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        InitializeView(dialogType, message)

    End Sub

    Private Sub InitializeView(ByVal dialogType As MessageDialogType, ByVal message As String)

        SetDialogImage(dialogType)
        txtMessage.Text = message

    End Sub

    Private Sub SetDialogImage(ByVal type As MessageDialogType)

        If type = MessageDialog.MessageDialogType.ErrorMessage Then
            pcbActionImage.Image = New Bitmap(GetType(ConfirmDialog), "ErrorDialog.png")
        End If

    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Public Enum MessageDialogType
        ErrorMessage = 0
    End Enum

End Class
